package dk.dashboardFP.interactionElementFramwork.buttonViews {
	import dk.dashboardFP.interactionElementFramwork.InteractionElementView;

	import flash.display.DisplayObject;
	import flash.display.Sprite;

	/**
	 * @author jk
	 */
	public class AbstractButtonView extends InteractionElementView {
		
		public static const DIRECTION_LEFT		:String	= "left";
		public static const DIRECTION_RIGHT		:String	= "right";
		public static const DIRECTION_UP		:String	= "up";
		public static const DIRECTION_DOWN		:String	= "down";
		
		protected var _direction		:String;
		
		public function AbstractButtonView() {
			setupButton();
			super();
		}
		
		//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
		// setup button
		//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
		
		protected function setupButton() : void {
			buttonMode=true;
			mouseChildren=false;
			
			enableLinked();
		}
		
		protected function disableButton() : void {
			buttonMode=false;
			disableLinked();
		}
		
		//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
		// button linked items
		//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

		override protected function registerLinkedDO(doLinkedItem : DisplayObject) : void {
			super.registerLinkedDO(doLinkedItem);
			enableLinked();
		}
		
		private function enableLinked() : void {
			for each (var sprLinkedItems : Sprite in _a_doLinkedDisplayObjects) {
				sprLinkedItems.buttonMode=true;
				sprLinkedItems.mouseChildren=false;
				sprLinkedItems.mouseEnabled=true;
			}
		}
		
		private function disableLinked() : void {
			for each (var sprLinkedItems : Sprite in _a_doLinkedDisplayObjects) {
				sprLinkedItems.buttonMode=false;
				sprLinkedItems.mouseChildren=false;
				sprLinkedItems.mouseEnabled=false;
			}
		}

		//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
		// select deselect
		//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
		
		override public function select() : void {
			super.select();
			if (_oIEHock.bDisableOnSelection) {
				disableButton();
			}
		}

		override public function deSelect() : void {
			super.deSelect();
			setupButton();
		}
		
		//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
		// disable enable
		//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
		
		override public function disable() : void {
			super.disable();
			disableButton();
		}

		override public function enable() : void {
			super.enable();
			setupButton();
		}
	}
}
